package project.dbaccesslayer;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class Table_Questions_To_Download {

	public static void saveQuestionsIds(Connection conn, List<Long> ids)
			throws SQLException {

		PreparedStatement s = conn
				.prepareStatement("INSERT INTO Questions_To_Download"
						+ "(Question_Id) VALUES(?)");
		for (Long id : ids) {
			s.setLong(1, id);
			s.executeUpdate();
		}

	}

	public static List<Long> getQuestionsToDownload(Connection conn)
			throws SQLException {
		PreparedStatement s = conn.prepareStatement("CALL GetQuestionsToDownload(); ");
		ResultSet r = s.executeQuery();
		List<Long> ids = new ArrayList<Long>();
		while (r.next()) {
			ids.add(r.getLong("Question_Id"));
		}
		return ids;
	}

}
